/*
 * @Author: your name
 * @Date: 2022-02-05 13:57:48
 * @LastEditTime: 2022-02-05 15:05:45
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /Wdjango/UI/request/index.js
 */
// 同时发送异步请求的次数
let ajaxTimes = 0;
// request method
export const request=(params)=>{
    ajaxTimes++;
    // 显示加载中效果
    wx.showLoading({
      title: 'Loading',
      mask: true
    });
    // base url
    const baseUrl = "http://127.0.0.1:8000/SimondeCapAPI"
    return new Promise((resolve, reject)=>{
        wx.request({
          ...params,
          url: baseUrl+params.url,
          success:(result)=>{
              resolve(result)
          },
          fail:(err)=>{
              reject(err)
          },
          complete:()=>{
            ajaxTimes--;
            if (ajaxTimes === 0) {
                wx.hideLoading();
            }
          }
        });
    })
}